package com.github.catvod.spider.merge;

/* loaded from: classes.dex */
public class KY {
    private int V0 = 0;
    private String h;

    public KY(String str) {
        R2.u(str);
        this.h = str;
    }

    private int PD() {
        return this.h.length() - this.V0;
    }

    public static String j5(String str) {
        StringBuilder V0 = ZG.V0();
        char[] charArray = str.toCharArray();
        int length = charArray.length;
        int i = 0;
        char c = 0;
        while (i < length) {
            char c2 = charArray[i];
            if (c2 != '\\') {
                V0.append(c2);
            } else if (c == '\\') {
                V0.append(c2);
            }
            i++;
            c = c2;
        }
        return ZG.t(V0);
    }

    public String BQ(String str) {
        int indexOf = this.h.indexOf(str, this.V0);
        if (indexOf == -1) {
            return y();
        }
        String substring = this.h.substring(this.V0, indexOf);
        this.V0 += substring.length();
        return substring;
    }

    public boolean F8(String str) {
        return this.h.regionMatches(true, this.V0, str, 0, str.length());
    }

    public String I() {
        int i = this.V0;
        while (!Qy() && (i4() || t('-', '_'))) {
            this.V0++;
        }
        return this.h.substring(i, this.V0);
    }

    public boolean Qy() {
        return PD() == 0;
    }

    public String V0(String str) {
        String BQ = BQ(str);
        oq(str);
        return BQ;
    }

    public String W(String... strArr) {
        int i = this.V0;
        while (!Qy() && !n(strArr)) {
            this.V0++;
        }
        return this.h.substring(i, this.V0);
    }

    /* JADX WARN: Removed duplicated region for block: B:21:0x0046 A[EDGE_INSN: B:21:0x0046->B:22:0x0046 BREAK  A[LOOP:0: B:2:0x0007->B:29:?], SYNTHETIC] */
    /* JADX WARN: Removed duplicated region for block: B:29:? A[LOOP:0: B:2:0x0007->B:29:?, LOOP_END, SYNTHETIC] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct add '--show-bad-code' argument
    */
    public java.lang.String h(char r10, char r11) {
        /*
            r9 = this;
            r0 = 0
            r1 = -1
            r2 = 0
            r3 = 0
            r4 = 0
            r5 = -1
            r6 = -1
        L7:
            boolean r7 = r9.Qy()
            if (r7 == 0) goto Le
            goto L46
        Le:
            char r7 = r9.j()
            r8 = 92
            if (r0 == r8) goto L3d
            r8 = 39
            if (r7 != r8) goto L21
            if (r7 == r10) goto L21
            if (r2 != 0) goto L21
            r4 = r4 ^ 1
            goto L2b
        L21:
            r8 = 34
            if (r7 != r8) goto L2b
            if (r7 == r10) goto L2b
            if (r4 != 0) goto L2b
            r2 = r2 ^ 1
        L2b:
            if (r4 != 0) goto L44
            if (r2 == 0) goto L30
            goto L44
        L30:
            if (r7 != r10) goto L39
            int r3 = r3 + 1
            if (r5 != r1) goto L3d
            int r5 = r9.V0
            goto L3d
        L39:
            if (r7 != r11) goto L3d
            int r3 = r3 + (-1)
        L3d:
            if (r3 <= 0) goto L43
            if (r0 == 0) goto L43
            int r6 = r9.V0
        L43:
            r0 = r7
        L44:
            if (r3 > 0) goto L7
        L46:
            if (r6 < 0) goto L4f
            java.lang.String r10 = r9.h
            java.lang.String r10 = r10.substring(r5, r6)
            goto L51
        L4f:
            java.lang.String r10 = ""
        L51:
            if (r3 <= 0) goto L6c
            java.lang.StringBuilder r11 = new java.lang.StringBuilder
            r11.<init>()
            java.lang.String r0 = "Did not find balanced marker at '"
            r11.append(r0)
            r11.append(r10)
            java.lang.String r0 = "'"
            r11.append(r0)
            java.lang.String r11 = r11.toString()
            com.github.catvod.spider.merge.R2.h(r11)
        L6c:
            return r10
        */
        throw new UnsupportedOperationException("Method not decompiled: com.github.catvod.spider.merge.KY.h(char, char):java.lang.String");
    }

    public boolean i4() {
        return !Qy() && Character.isLetterOrDigit(this.h.charAt(this.V0));
    }

    public boolean iU() {
        return !Qy() && ZG.u(this.h.charAt(this.V0));
    }

    public char j() {
        String str = this.h;
        int i = this.V0;
        this.V0 = i + 1;
        return str.charAt(i);
    }

    public boolean n(String... strArr) {
        for (String str : strArr) {
            if (F8(str)) {
                return true;
            }
        }
        return false;
    }

    public String oC() {
        int i = this.V0;
        while (!Qy() && (i4() || n("*|", "|", "_", "-"))) {
            this.V0++;
        }
        return this.h.substring(i, this.V0);
    }

    public boolean oq(String str) {
        if (!F8(str)) {
            return false;
        }
        this.V0 += str.length();
        return true;
    }

    public void q(String str) {
        if (!F8(str)) {
            throw new IllegalStateException("Queue did not match expected sequence");
        }
        int length = str.length();
        if (length > PD()) {
            throw new IllegalStateException("Queue not long enough to consume sequence");
        }
        this.V0 += length;
    }

    public boolean t(char... cArr) {
        if (Qy()) {
            return false;
        }
        for (char c : cArr) {
            if (this.h.charAt(this.V0) == c) {
                return true;
            }
        }
        return false;
    }

    public String toString() {
        return this.h.substring(this.V0);
    }

    public boolean u() {
        boolean z = false;
        while (iU()) {
            this.V0++;
            z = true;
        }
        return z;
    }

    public String y() {
        String substring = this.h.substring(this.V0);
        this.V0 = this.h.length();
        return substring;
    }
}
